import { RouteRecordRaw } from 'vue-router';

export const P_ROUTER = {
  ROOT: {
    path: '/personal',
    name: 'personal',
    title: '个人中心',
  },
  PERSONAL_CENTER: {
    path: '/personal/personal-center',
    name: 'personal-center',
    title: '我的中心',
  },
  ADDRESS_MANAGEMENT: {
    path: '/personal/address-management',
    name: 'address-management',
    title: '地址管理',
  },
  PERSONAL_ORDERS: {
    path: '/personal/personal-orders',
    name: 'personal-orders',
    title: '我的订单',
  },
  PERSONAL_INFO: {
    path: '/personal/personal-info',
    name: 'personal-info',
    title: '个人信息',
  },
  EDIT_PASSWORD: {
    path: '/personal/edit-password',
    name: 'edit-password',
    title: '修改密码',
  },
};

const personalRoutes: RouteRecordRaw = {
  path: P_ROUTER.ROOT.path,
  name: P_ROUTER.ROOT.name,
  meta: {
    title: P_ROUTER.ROOT.title,
  },
  component: () => import('@/views/personal/index.vue'),
  redirect: P_ROUTER.PERSONAL_CENTER.path,
  children: [
    {
      path: P_ROUTER.PERSONAL_CENTER.path,
      name: P_ROUTER.PERSONAL_CENTER.name,
      meta: {
        title: P_ROUTER.PERSONAL_CENTER.title,
      },
      component: () =>
        import('@/views/personal/personal-center/personal-center.vue'),
    },
    {
      path: P_ROUTER.ADDRESS_MANAGEMENT.path,
      name: P_ROUTER.ADDRESS_MANAGEMENT.name,
      meta: {
        title: P_ROUTER.ADDRESS_MANAGEMENT.title,
      },
      component: () =>
        import('@/views/personal/personal-center/address-mg.vue'),
    },
    {
      path: P_ROUTER.PERSONAL_ORDERS.path,
      name: P_ROUTER.PERSONAL_ORDERS.name,
      meta: {
        title: P_ROUTER.PERSONAL_ORDERS.title,
      },
      component: () =>
        import('@/views/personal/transaction/personal-orders.vue'),
    },
    {
      path: P_ROUTER.PERSONAL_INFO.path,
      name: P_ROUTER.PERSONAL_INFO.name,
      meta: {
        title: P_ROUTER.PERSONAL_INFO.title,
      },
      component: () => import('@/views/personal/account-mgt/personal-info.vue'),
    },
    {
      path: P_ROUTER.EDIT_PASSWORD.path,
      name: P_ROUTER.EDIT_PASSWORD.name,
      meta: {
        title: P_ROUTER.EDIT_PASSWORD.title,
      },
      component: () => import('@/views/personal/account-mgt/edit-password.vue'),
    },
  ],
};

export default personalRoutes;
